package io.renren.modules.jsf.service.impl;

import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.jsf.dao.EquipmentDao;
import io.renren.modules.jsf.entity.EquipmentEntity;
import io.renren.modules.jsf.service.EquipmentService;


@Service("equipmentService")
public class EquipmentServiceImpl extends ServiceImpl<EquipmentDao, EquipmentEntity> implements EquipmentService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        IPage<EquipmentEntity> page = null;
        if (StringUtils.isNotEmpty(key)) {
            page = this.page(
                    new Query<EquipmentEntity>().getPage(params),
                    new QueryWrapper<EquipmentEntity>().like("eqName", key)
            );
        } else {
            page = this.page(
                    new Query<EquipmentEntity>().getPage(params),
                    new QueryWrapper<EquipmentEntity>()
            );
        }

        return new PageUtils(page);
    }

}
